//
//  UITableView+NoData.m
//  Jxlq
//
//  Created by ZDTX on 2021/7/21.
//

#import "UITableView+NoData.h"
#import "UIView+LX_Frame.h"

@implementation UITableView (NoData)

- (void)showDataCount:(NSInteger)count{
    if (count > 0) {
        self.backgroundView = nil;
        return;
    }
    
    UIView *backgroundView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.lx_width, self.lx_height)];
    
    UIImageView *showImageView = [[UIImageView alloc]init];
    showImageView.image = [UIImage imageNamed:@"nodata"];
    showImageView.contentMode = UIViewContentModeScaleAspectFit;
    [backgroundView addSubview:showImageView];
    
    UILabel * label = [[UILabel alloc] init];
    label.textColor = [UIColor colorWithHexString:@"666666" alpha:1.0];
    label.font = [UIFont systemFontOfSize:14.f];
    label.textAlignment = NSTextAlignmentCenter;
    label.text = @"暂无数据～";
    [backgroundView addSubview:label];

    
    [showImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(backgroundView.mas_centerX);
        make.centerY.equalTo(backgroundView.mas_centerY).mas_offset(-20);
        make.size.mas_equalTo(CGSizeMake(91.0f, 78.0f));
    }];
    
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(backgroundView.mas_centerX);
        make.top.equalTo(showImageView.mas_bottom).mas_offset(30);
    }];
    
    self.backgroundView = backgroundView;
    
}

- (void)showDataWithString:(NSString *)string{
    if (string.length > 0) {
        self.backgroundView = nil;
        return;
    }
    UIView *backgroundView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.lx_width, self.lx_height)];
    
    UIImageView *showImageView = [[UIImageView alloc]init];
    showImageView.image = [UIImage imageNamed:@"nodata"];
    showImageView.contentMode = UIViewContentModeScaleAspectFit;
    [backgroundView addSubview:showImageView];
    
    UILabel * label = [[UILabel alloc] init];
    label.textColor = [UIColor colorWithHexString:@"666666" alpha:1.0];
    label.font = [UIFont systemFontOfSize:14.f];
    label.textAlignment = NSTextAlignmentCenter;
    label.text = @"还未生成值班报告,无法查看~";
    [backgroundView addSubview:label];

    
    [showImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(backgroundView.mas_centerX);
        make.centerY.equalTo(backgroundView.mas_centerY).mas_offset(-20);
        make.size.mas_equalTo(CGSizeMake(91.0f, 78.0f));
    }];
    
    [label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(backgroundView.mas_centerX);
        make.top.equalTo(showImageView.mas_bottom).mas_offset(30);
    }];
    
    self.backgroundView = backgroundView;
}

@end
